package com.virtualightning.mvvm.widget

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.viewpager.widget.ViewPager

/**
 *  Anchor : Create by CimZzz
 *  Time : 2021/12/29 16:15
 *  左右滑动 ViewPager
 */
class SlideViewPager: ViewPager {
	constructor(context: Context) : super(context)
	constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)

	/**
	 * 判断是否允许左右滑动
	 */
	private var isAllowSliding = true

	override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
		return if(isAllowSliding) super.onInterceptTouchEvent(ev) else false
	}

	fun setAllowSliding(isAllowSliding: Boolean) {
		this.isAllowSliding = isAllowSliding
	}
}